﻿using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Newtonsoft.Json;

namespace LeafulWeiboSdk.Metadata
{
    public class StatusMetadata : BaseMetadata
    {
        /// <summary>
        /// 微博创建时间
        /// </summary>
        [JsonProperty("created_at")]
        public string CreatedAt { get; set; }
        /// <summary>
        /// 微博ID
        /// </summary>
        [JsonProperty("id")]
        public string Id { get; set; }
        /// <summary>
        /// 微博信息内容
        /// </summary>
        [JsonProperty("text")]
        public string Text { get; set; }
        /// <summary>
        /// 微博来源
        /// </summary>
        [JsonProperty("source")]
        public string Source { get; set; }
        /// <summary>
        /// 是否已收藏，true：是，false：否
        /// </summary>
        [JsonProperty("favorited")]
        public bool Favorited { get; set; }
        /// <summary>
        /// 是否被截断，true：是，false：否
        /// </summary>
        [JsonProperty("truncated")]
        public bool Truncated { get; set; }
        /// <summary>
        /// 缩略图片地址,没有时为null
        /// </summary>
        [JsonProperty("thumbnail_pic")]
        public string ThumbnailPictureUrl { get; set; }
        /// <summary>
        /// 中等尺寸图片地址，没有时不返回此字段
        /// </summary>
        [JsonProperty("bmiddle_pic")]
        public string MiddleSizePictureUrl { get; set; }
        /// <summary>
        /// 原始图片地址，没有时不返回此字段
        /// </summary>
        [JsonProperty("original_pic")]
        public string OriginalPictureUrl { get; set; }
        /// <summary>
        /// 微博MID
        /// </summary>
        [JsonProperty("mid")]
        public string Mid { get; set; }
        /// <summary>
        /// 转发数
        /// </summary>
        [JsonProperty("reposts_count")]
        public int RepostsCount { get; set; }
        /// <summary>
        /// 评论数
        /// </summary>
        [JsonProperty("comments_count")]
        public int CommentsCount { get; set; }
        /// <summary>
        /// 表态数
        /// </summary>
        [JsonProperty("annotations")]
        public List<AnnotationsMetadata> Annotations { get; set; }
        /// <summary>
        /// 地理信息
        /// </summary>
        [JsonProperty("geo")]
        public GeoMetadata Geo { get; set; }
        /// <summary>
        /// 微博作者的用户信息
        /// </summary>
        [JsonProperty("user")]
        public UserMetadata User { get; set; }
        /// <summary>
        /// 被转发的原微博
        /// </summary>
        [JsonProperty("retweeted_status")]
        public StatusMetadata RetweetedStatus { get; set; }
        [JsonProperty("pic_urls")]
        public List<PicMetadata> PicUrls { get; set; }


        // extend
        /// <summary>
        /// （扩展）获取微博创建时间
        /// </summary>
        public DateTime CreatedAtDataTime { get { return Swap.GetTimeFromCreatAt(CreatedAt); } }
        /// <summary>
        /// （扩展）获取单条微博页面Url
        /// </summary>
        public string Url { get { return Swap.GetUrlFromId(Id, User.Id); } }

    }

    public class StatusCollectionMetadata : BaseMetadata
    {
        [JsonProperty("statuses")]
        public List<StatusMetadata> Statuses { get; set; }
        [JsonProperty("total_number")]
        public int TotalNumber { get; set; }
    }

    public class RepostsCollectionMetadata : BaseMetadata
    {
        [JsonProperty("reposts")]
        public List<StatusMetadata> Reposts { get; set; }
        [JsonProperty("total_number")]
        public int TotalNumber { get; set; }
    }

    public enum StatusType
    {
        All = 0,
        Original = 1,
        Picture = 2,
        Video = 3,
        Music = 4
    }
}
